//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
//==========================================================================
// Copyright (c) 2000-2004,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#ifndef __RTL_8139_H__
#define __RTL_8139_H__
#include "rtl8139.h"

extern int      rtl_8139xmit(netdrv* pThis);
extern void     rtl_8139_stutdown(netdrv *pThis);

extern netdrv * rtl_8139new(int *pPortBase,  int * pIrq,  int *pMedia, int deviceNo);
extern int      rtl_8139_connect(void * softc, void** hardc, netdrv *pRtl, Thread **ppThread);

#define DRVINITALIZE    0x00000001
#define ENABLEIRQ       0x00000002
#define DISABLEIRQ      0x00000003
#define DRVSHUTDOWN     0x00000004

#define MAX_ETH_DEVICENAME_LENGTH    16

class Rtl4If : public CDeviceDriver {
public:
    CARAPI Read(
        /* [in] */ Int64 u64Offset,
        /* [in] */ Int32 bytesToRead,
        /* [out] */ MemoryBuf * pBuffer,
        /* [out] */ IEvent * * ppCompletionEvent);

    CARAPI Write(
        /* [in] */ Int64 u64Offset,
        /* [in] */ const MemoryBuf & buffer,
        /* [out] */ Int32 * pBytesWritten,
        /* [out] */ IEvent * * ppCompletionEvent);

    CARAPI Control(
        /* [in] */ Handle32 nControlCode,
        /* [in] */ const MemoryBuf & inBuffer,
        /* [out] */ MemoryBuf * pOutBuffer,
        /* [out] */ IEvent * * ppCompletionEvent);

    virtual void Dispose();
    Rtl4If(Int32 deviceNo);

public:
    Int32 m_deviceNo;
    Node m_nodeReadList;
    Node m_nodeWriteList;
    netdrv *m_pRtl;
    wchar_t m_deviceName[MAX_ETH_DEVICENAME_LENGTH];
    Thread *m_pIstThread;
private:
    void* m_rtl8139;
};

#endif//__RTL_8139_H__

